package com.eques.demo.adapter.viewhoder

import android.content.Context
import android.text.format.DateUtils
import android.view.View
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView

import androidx.recyclerview.widget.RecyclerView
import com.eques.bean.DataBean
import com.eques.demo.R
import com.eques.util.EquesMytool
import com.eques.util.EquesPreference
import org.apache.commons.lang3.StringUtils


@Suppress("DEPRECATION")
class MsgDetailHoder(itemView: View?) : RecyclerView.ViewHolder(itemView!!) {

    private val tv_animal_hours: TextView = itemView!!.findViewById(R.id.tv_animal_hours)
    private val tv_animal_content: TextView = itemView!!.findViewById(R.id.tv_animal_content)
    private val rel_animal_data: RelativeLayout =itemView!!.findViewById(R.id.rel_animal_data)
    private var iv_alarm_type: ImageView =itemView!!.findViewById(R.id.iv_alarm_type)
    fun setData(
        context: Context,
        tabE1ProAlarmMsgInfo: List<DataBean>,
        position: Int
    ) {
        tv_animal_hours.text =
            EquesMytool(context).getHD(tabE1ProAlarmMsgInfo[position].createTime)
        tv_animal_content.text = context.getString(R.string.animal_send_food_number)
            .replace("s%", "" + tabE1ProAlarmMsgInfo[position].number)
        var fid=tabE1ProAlarmMsgInfo[position].previewFileId
        if(StringUtils.isEmpty(fid)){
            rel_animal_data.visibility=View.GONE
        }else{
            rel_animal_data.visibility=View.VISIBLE
            if (tabE1ProAlarmMsgInfo[position].category == 2) {
                iv_alarm_type.visibility=View.VISIBLE
            } else {
                iv_alarm_type.visibility=View.GONE
            }
        }

    }
}